import {get, post} from '@/http/axios'
export default {
    namespaced: true,
    state: {
        f_categories: []
    },
    mutations: {
        // 通过突变修改f_categories
        refreshFindAllCategory(state,data) {
            state.f_categories = data
        }
    },
    actions: {
        // 删除
        async deleteCategory({dispatch},id) {
            let response = await get("/category/deleteById?id="+id)
            return response.data
        },
        // 保存
        async saveOrUpdateCategory({dispatch},params) {
            let response = await post("/category/saveOrUpdate",params)
            return response.data
        },
        // 查询所有栏目
        async findAllCategory({commit}) {
            let response = await get("/category/findAll")
            commit("refreshFindAllCategory",response.data.data)
        }
    }
}